package org.rambadger.command.event;


import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.rambadger.command.validation.UrlIdentifier;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * Event representing the creation of a {@link org.rambadger.command.model.TrackEntity track} under a {@link org.rambadger.command.model.PlatformAggregate Plaform}.
 */
public class TrackCreated implements Serializable {
    private static final long serialVersionUID = -5097514946665580478L;
    //Compound Key {
    private final String platformId;
    private final String trackId;
    //}
    private final String trackName;
    private final String description;

    /**
     * Instantiates a new Track created.
     *
     * @param platformId the platform id
     * @param trackId the per platform unique identifier for the track
     * @param trackName the track name/title
     * @param description the description
     */
    public TrackCreated(String platformId, String trackId, String trackName, String description) {
        this.platformId = platformId;
        this.trackId = trackId;
        this.trackName = trackName;
        this.description = description;
    }

    /**
     * Gets the id of the platform that the track belongs to
     *
     * @return the platform id
     */
    @UrlIdentifier @NotNull
    public String getPlatformId() {
        return platformId;
    }

    /**
     * Gets the identifier for the new track.
     *
     * @return the track id
     */
    @UrlIdentifier @NotNull
    public String getTrackId() {
        return trackId;
    }

    /**
     * Gets track name/title.
     *
     * @return the track name
     */
    @Length(max = 64) @NotBlank
    public String getTrackName() {
        return trackName;
    }

    /**
     * Gets the description.
     *
     * @return the description
     */
    @Length(max = 4096) @NotBlank
    public String getDescription() {
        return description;
    }

    public String getFullTrackId() {
        return platformId+"/"+trackId;
    }

    @Override
    public String toString() {
        return "TrackCreated{" +
                "platformId='" + platformId + '\'' +
                ", trackId='" + trackId + '\'' +
                ", trackName='" + trackName + '\'' +
                ", description='" + description + '\'' +
                '}';
    }
}
